<template>
  <div>
    <el-dialog :title="option.title" :visible.sync="isShow" :close-on-click-modal="false" width="60%" @open="openDialog"
      @close="closeDialog">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" size="small">
       <el-row>
        <el-col :span="13">
            <el-form-item label="机构名称" prop="branchNO">
              <select-tree :tree-data="option.treedata" :branch="ruleForm.branchName" @getBranchName="getBranch"></select-tree>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="分配规则名称" prop="ASSIGNRULENAME">
              <el-input v-model="ruleForm.ASSIGNRULENAME" size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="优先级" prop="PRIORITY">
              <el-input-number v-model="ruleForm.PRIORITY" size="small" controls-position="right" :min="1" :max="10">
              </el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="EFFECTDATE" label="生效日期">
              <el-date-picker size="small" v-model="ruleForm.EFFECTDATE" type="date" value-format="yyyyMMdd"
                placeholder="生效日期" :picker-options="pickerOptionsStart" @change="changeStart">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="FAILUREDATE" label="失效日期">
              <el-date-picker size="small" v-model="ruleForm.FAILUREDATE" type="date" value-format="yyyyMMdd"
                placeholder="失效日期" :picker-options="pickerOptionsEnd" @change="changeEnd">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="16">
            <el-form-item label="规则类型" prop="RULETYPE">
              <el-radio-group v-model="ruleForm.RULETYPE" @change="ruleTypeChange">
                <el-radio :label="'1'">坐席必须工作</el-radio>
                <el-radio :label="'2'">坐席必须休假</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="24" v-if="ruleForm.RULETYPE">
            <el-tabs v-model="ruleForm.RULETYPE" type="card" @tab-click="handleClick">
              <!-- 必须工作 -->
              <el-tab-pane :label="ruleTypeName" name="1" v-if="ruleForm.RULETYPE=='1'">
                <!-- 选择规则类型的操作单位 -->
                <el-col :span="24">
                  <el-collapse v-model="activeNames">
                    <el-collapse-item name="1">
                      <template slot="title">
                        <i class="header-icon el-icon-user-solid"></i> &nbsp;操作单位
                      </template>
                      <div style="margin-left:80px;">
                        <el-radio-group v-model="ruleForm.OPERUNIT" @change="operateChange">
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'1'">
                              班次&nbsp;&nbsp;&nbsp;
                              <el-select class="selectStyle" size="small" :disabled="ruleForm.OPERUNIT!='1'"
                                v-model="ruleForm.value1">
                                <el-option v-for="item in classOption" :key="item.ACTIVITYTYPE"
                                  :label="item.ACTIVITYTYPENAME" :value="item.ACTIVITYTYPE">
                                </el-option>
                              </el-select>
                            </el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'2'">班次事件&nbsp;&nbsp;&nbsp;
                              <el-select class="selectStyle" size="small" :disabled="ruleForm.OPERUNIT!='2'"
                                v-model="ruleForm.value2">
                                <el-option v-for="item in classEventOption" :key="item.ACTIVITYTYPE"
                                  :label="item.ACTIVITYTYPENAME" :value="item.ACTIVITYTYPE">
                                </el-option>
                              </el-select>
                            </el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'3'">天</el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'4'">工作日
                              <el-select class="selectStyle" size="small" :disabled="ruleForm.OPERUNIT!='4'"
                                v-model="ruleForm.value4">
                                <el-option v-for="item in dayOption" :key="item.value" :label="item.label"
                                  :value="item.value">
                                </el-option>
                              </el-select>
                            </el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'5'">部分周末
                              <!-- <el-select class="selectStyle" size="small" :disabled="ruleForm.OPERUNIT!='5'"
                                v-model="ruleForm.value5">
                                <el-option label="星期六" value="6"></el-option>
                                <el-option label="星期天" value="7"></el-option>
                              </el-select> -->
                            </el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'6'">完整周末</el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'7'">小时</el-radio>
                          </el-col>
                          <el-col :span="13">
                            <el-radio :label="'8'">连续工作日</el-radio>
                          </el-col>
                        </el-radio-group>
                      </div>
                    </el-collapse-item>
                    <el-collapse-item name="2" v-if="ruleForm.OPERUNIT">
                      <template slot="title">
                        <i class="header-icon el-icon-s-help"></i> &nbsp;操作周期
                      </template>
                      <div style="margin-left:80px;">
                        <el-radio-group v-model="ruleForm.OPERPERIOD" @change="operateChange">
                          <el-col :span="13"
                            v-if="ruleForm.OPERUNIT == '1' || ruleForm.OPERUNIT == '2'|| ruleForm.OPERUNIT == '7'"
                            style="margin-bottom:15px;">
                            <el-radio :label="'1'">每 <el-input v-model="ruleForm.VALUEX1" size="mini"
                                :disabled="ruleForm.OPERPERIOD !='1'" class="selectStyle"></el-input> 天</el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'2'">每 <el-input v-model="ruleForm.VALUEX2" size="mini"
                                :disabled="ruleForm.OPERPERIOD !='2'" class="selectStyle"></el-input> 周</el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'3'">每 <el-input v-model="ruleForm.VALUEX3" size="mini"
                                :disabled="ruleForm.OPERPERIOD !='3'" class="selectStyle"></el-input> 月</el-radio>
                          </el-col>
                          <el-col :span="13" v-if="ruleForm.RULETYPE !='8'" style="margin-bottom:15px;">
                            <el-radio :label="'4'">每28天的月份</el-radio>
                          </el-col>
                          <el-col :span="13" v-if="ruleForm.RULETYPE !='8'" style="margin-bottom:15px;">
                            <el-radio :label="'5'">每29天的月份</el-radio>
                          </el-col>
                          <el-col :span="13" v-if="ruleForm.RULETYPE !='8'" style="margin-bottom:15px;">
                            <el-radio :label="'6'">每30天的月份</el-radio>
                          </el-col>
                          <el-col :span="13" v-if="ruleForm.RULETYPE !='8'" style="margin-bottom:15px;">
                            <el-radio :label="'7'">每31天的月份</el-radio>
                          </el-col>
                        </el-radio-group>
                      </div>
                    </el-collapse-item>
                    <el-collapse-item name="3" v-if="ruleForm.OPERPERIOD">
                      <template slot="title">
                        <i class="header-icon el-icon-data-line"></i> &nbsp;操作单位数量
                      </template>
                      <div>
                        <el-radio-group v-model="ruleForm.number">
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'1'">至少 <el-input v-model="ruleForm.number1" size="mini"
                                :disabled="ruleForm.number !='1'" class="selectStyle"></el-input>
                            </el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'2'">不超过 <el-input v-model="ruleForm.number2" size="mini"
                                :disabled="ruleForm.number !='2'" class="selectStyle"></el-input>
                            </el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'3'">正好 <el-input v-model="ruleForm.number3" size="mini"
                                :disabled="ruleForm.number !='3'" class="selectStyle"></el-input>
                            </el-radio>
                          </el-col>
                          <el-col :span="13" v-if="ruleForm.RULETYPE !='8'" style="margin-bottom:15px;">
                            <el-radio :label="'4'">
                              介于 <el-input v-model="ruleForm.number4" size="mini" :disabled="ruleForm.number !='4'"
                                class="selectStyle">
                              </el-input>到&nbsp; &nbsp;
                              <el-input v-model="ruleForm.number5" size="mini" :disabled="ruleForm.number !='4'"
                                class="selectStyle"> 之间
                              </el-input>
                            </el-radio>
                          </el-col>
                        </el-radio-group>
                      </div>
                    </el-collapse-item>
                  </el-collapse>
                </el-col>
              </el-tab-pane>
              <el-tab-pane :label="ruleTypeName" name="2" v-if="ruleForm.RULETYPE=='2'">
                <el-col :span="24">
                  <el-collapse v-model="activeNames">
                    <el-collapse-item name="1">
                      <template slot="title">
                        <i class="header-icon el-icon-user-solid"></i> &nbsp;操作单位
                      </template>
                      <div style="margin-left:80px;">
                        <el-radio-group v-model="ruleForm.OPERUNIT" @change="operateChange">
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'3'">天</el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'4'">工作日
                              <el-select class="selectStyle" size="small" :disabled="ruleForm.OPERUNIT!='4'"
                                v-model="ruleForm.value4">
                                <el-option v-for="item in dayOption" :key="item.value" :label="item.label"
                                  :value="item.value">
                                </el-option>
                              </el-select>
                            </el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'5'">部分周末
                              <!-- <el-select class="selectStyle" size="small" :disabled="ruleForm.OPERUNIT!='5'"
                                v-model="ruleForm.value5">
                                <el-option label="星期六" value="6"></el-option>
                                <el-option label="星期天" value="7"></el-option>
                              </el-select> -->
                            </el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'6'">完整周末</el-radio>
                          </el-col>
                        </el-radio-group>
                      </div>
                    </el-collapse-item>
                    <el-collapse-item name="2" v-if="ruleForm.OPERUNIT">
                      <template slot="title">
                        <i class="header-icon el-icon-s-help"></i> &nbsp;操作周期
                      </template>
                      <div style="margin-left:80px;">
                        <el-radio-group v-model="ruleForm.OPERPERIOD" @change="operateChange">
                          <!-- <el-col :span="13"
                            v-if="ruleForm.RULETYPE=='1'&&(ruleForm.OPERUNIT == '1' || ruleForm.OPERUNIT == '2'|| ruleForm.OPERUNIT == '7')"
                            style="margin-bottom:15px;">
                            <el-radio :label="1">每 <el-input v-model="ruleForm.VALUEX1" size="mini"
                                :disabled="ruleForm.OPERPERIOD !='1'" class="selectStyle"></el-input> 天</el-radio>
                          </el-col> -->
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'2'">每 <el-input v-model="ruleForm.VALUEX2" size="mini"
                                :disabled="ruleForm.OPERPERIOD !='2'" class="selectStyle"></el-input> 周</el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'3'">每 <el-input v-model="ruleForm.VALUEX3" size="mini"
                                :disabled="ruleForm.OPERPERIOD !='3'" class="selectStyle"></el-input> 月</el-radio>
                          </el-col>
                          <el-col :span="13" v-if="ruleForm.RULETYPE !='8'" style="margin-bottom:15px;">
                            <el-radio :label="'4'">每28天的月份</el-radio>
                          </el-col>
                          <el-col :span="13" v-if="ruleForm.RULETYPE !='8'" style="margin-bottom:15px;">
                            <el-radio :label="'5'">每29天的月份</el-radio>
                          </el-col>
                          <el-col :span="13" v-if="ruleForm.RULETYPE !='8'" style="margin-bottom:15px;">
                            <el-radio :label="'6'">每30天的月份</el-radio>
                          </el-col>
                          <el-col :span="13" v-if="ruleForm.RULETYPE !='8'" style="margin-bottom:15px;">
                            <el-radio :label="'7'">每31天的月份</el-radio>
                          </el-col>
                        </el-radio-group>
                      </div>
                    </el-collapse-item>
                    <el-collapse-item name="3" v-if="ruleForm.OPERPERIOD">
                      <template slot="title">
                        <i class="header-icon el-icon-data-line"></i> &nbsp;操作单位数量
                      </template>
                      <div>
                        <el-radio-group v-model="ruleForm.number">
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'1'">至少 <el-input v-model="ruleForm.number1" size="mini"
                                :disabled="ruleForm.number !='1'" class="selectStyle"></el-input>
                            </el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'2'">不超过 <el-input v-model="ruleForm.number2" size="mini"
                                :disabled="ruleForm.number !='2'" class="selectStyle"></el-input>
                            </el-radio>
                          </el-col>
                          <el-col :span="13" style="margin-bottom:15px;">
                            <el-radio :label="'3'">正好 <el-input v-model="ruleForm.number3" size="mini"
                                :disabled="ruleForm.number !='3'" class="selectStyle"></el-input>
                            </el-radio>
                          </el-col>
                          <el-col :span="13" v-if="ruleForm.RULETYPE !='8'" style="margin-bottom:15px;">
                            <el-radio :label="'4'">
                              介于 <el-input v-model="ruleForm.number4" size="mini" :disabled="ruleForm.number !='4'"
                                class="selectStyle">
                              </el-input>&nbsp;到 &nbsp;
                              <el-input v-model="ruleForm.number5" size="mini" :disabled="ruleForm.number !='4'"
                                class="selectStyle"> 
                              </el-input> &nbsp;之间
                            </el-radio>
                          </el-col>
                        </el-radio-group>
                      </div>
                    </el-collapse-item>
                  </el-collapse>
                </el-col>
              </el-tab-pane>
            </el-tabs>
          </el-col>
        <el-col :span="10" :offset="14" style="margin-top:18px;">
            <el-form-item>
              <el-button type="primary" size="small" @click="submitForm('ruleForm')">保存</el-button>
              <el-button size="small" type="danger" @click="resetForm('ruleForm')">重置</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
  import request from "@/common/utils/requestWFM";
  import activityQuery from '@/message/wfm/scheduleDataManage/activityManage/actQuery';
  import Add from '@/message/wfm/scheduleDataManage/assignRules/assignAdd';
  import selectTree from "@/components/selectTree5/";

  export default {
    components: {
      selectTree
    },
    props: {
      option: Object
    },
    data() {
      return {
        defaultProps: {
            children: 'children',
            label: 'BRANCHNAME'
          },
          popoverShow: false,
        activeNameTab: 'first',
        dayOption: [{
            value: '1',
            label: '星期一'
          },
          {
            value: '2',
            label: '星期二'
          },
          {
            value: '3',
            label: '星期三'
          },
          {
            value: '4',
            label: '星期四'
          },
          {
            value: '5',
            label: '星期五'
          },
          {
            value: '6',
            label: '星期六'
          },
          {
            value: '7',
            label: '星期日'
          },
        ],
        classEventOption: [],
        classOption: [],
        pickerOptionsStart: {
          disabledDate: (time) => {
            return time.getTime() < Date.now()-24 * 60 * 60 * 1000
          }
        },
        pickerOptionsEnd: {
          disabledDate: (time) => {
            return time.getTime() < Date.now()-24 * 60 * 60 * 1000
          }
        },
        activeNames: ['1', '2', '3'],
        ruleTypeName: '', //规则类型名称
        ruleForm: {
          value1: '',
          value2: '',
          value4: '',
          // value5: '',
          ASSIGNRULENAME: '', // 分配规则名称
          PRIORITY: 1, //优先级 
          RULETYPE: '', //规则类型
          OPERUNIT: '', //操作单位
          OPERPERIOD: '', // 操作周期
          VALUEX: '', // 周期X的值
          VALUEX1: '', // 周期X的值
          VALUEX2: '', // 周期X的值
          VALUEX3: '', // 周期X的值
          UNITMINVALUE: '', // 操作单位数量最小限制
          UNITMAXVALUE: '', //操作单位数量最大限制
          EFFECTDATE: '', // 生效日期
          FAILUREDATE: '', // 失效日期
          number: '',
          number1: '',
          number2: '',
          number3: '',
          number4: '',
          number5: '',
          branchNO: '',
          branchName: ''
        },
        rules: {
          ASSIGNRULENAME: [{
              required: true,
              message: '请输入分配规则名称',
              trigger: 'blur'
            },
            {
              min: 2,
              max: 10,
              message: '长度在 2 到 10 个字符',
              trigger: 'blur'
            }
          ],
          branchNO: [{
                required: true,
                message: '请选择机构名称',
                trigger: 'change'
              }
            ],
          RULETYPE: [{
            required: true,
            message: '请选择规则类型',
            trigger: 'change'
          }],
          OPERUNIT: [{
            required: true,
            message: '请选择操作单位',
            trigger: 'change'
          }],
          OPERPERIOD: [{
            required: true,
            message: '请选择操作周期',
            trigger: 'change'
          }],
          EFFECTDATE: [{
            required: true,
            message: '请输入生效日期',
            trigger: 'blur'
          }],
          FAILUREDATE: [{
            required: true,
            message: '请输入失效日期',
            trigger: 'blur'
          }],
        },
      }
    },
    computed: {
      isShow: {
        get() {
          return this.option.isShow;
        },
        set(value) {
          this.option.isShow = value;
        }
      }
    },
    methods: {
      getBranch(data) {
          this.ruleForm.branchName = data.BRANCHNAME
          this.ruleForm.branchNO = data.BRANCHNO
          this.popoverShow = false
        },
      handleClick() {
        this.ruleForm.OPERPERIOD = ''
        this.ruleForm.OPERUNIT = ''
        this.ruleForm.value1 = ''
        this.ruleForm.value2 = ''
        this.ruleForm.value4 = ''
        // this.ruleForm.value5 = ''
        this.ruleForm.VALUEX = ''
        this.ruleForm.VALUEX1 = ''
        this.ruleForm.VALUEX2 = ''
        this.ruleForm.VALUEX3 = ''
        this.ruleForm.number= ''
        this.ruleForm.number1=''
        this.ruleForm.number2=''
        this.ruleForm.number3=''
        this.ruleForm.number4=''
        this.ruleForm.number5=''
      },
      async actQuery(name) {
        let resBody = new activityQuery()
        resBody.data.ACTIVITYCATEG = name
        resBody.data.CurrPage = 1
        resBody.data.PageRowNum = 20
        let response = await request(resBody);
        if (response.SYS_HEAD.ReturnCode == "000000") {
          if (name == '01') {
            this.classOption = response.BODY.RSPSTRUCT
          } else {
            this.classEventOption = response.BODY.RSPSTRUCT
          }
        } else {
          this.$message({
            type: "error",
            message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
          })
        }
      },
      changeStart() {
        this.pickerOptionsEnd = Object.assign({}, this.pickerOptionsEnd, {
          disabledDate: (time) => {
            if (this.ruleForm.EFFECTDATE) {
              return time.getTime() < Date.parse(this.ruleForm.EFFECTDATE.slice(0, 4) + '-' + this.ruleForm
                .EFFECTDATE.slice(4, 6) +
                '-' + this.ruleForm.EFFECTDATE.slice(6, 8)) - 8.64e7 || time.getTime() < Date.now()-24 * 60 * 60 * 1000;
            } else {
              return time.getTime() < Date.now()-24 * 60 * 60 * 1000;
            }
          }
        })
      },
      changeEnd() {
        this.pickerOptionsStart = Object.assign({}, this.pickerOptionsStart, {
          disabledDate: (time) => {
            if (this.ruleForm.FAILUREDATE) {
              return time.getTime() > Date.parse(this.ruleForm.FAILUREDATE.slice(0, 4) + '-' + this.ruleForm
                .FAILUREDATE
                .slice(4, 6) + '-' +
                this.ruleForm.FAILUREDATE.slice(6, 8)) || time.getTime() < Date.now()-24 * 60 * 60 * 1000;
            } else {
              return time.getTime() < Date.now()-24 * 60 * 60 * 1000
            }
          }
        })
      },
      // 操作单位修改
      operateChange(val) {
        // console.log(val)
      },
      closeDialog() {
        this.$refs['ruleForm'].clearValidate();
        this.$refs['ruleForm'].resetFields();
        this.ruleForm.OPERPERIOD = ''
        this.ruleForm.OPERUNIT = ''
        this.ruleForm.value1 = ''
        this.ruleForm.value2 = ''
        this.ruleForm.value4 = ''
        // this.ruleForm.value5 = ''
        this.ruleForm.VALUEX = ''
        this.ruleForm.VALUEX1 = ''
        this.ruleForm.VALUEX2 = ''
        this.ruleForm.VALUEX3 = ''
        this.ruleForm.number= ''
        this.ruleForm.number1=''
        this.ruleForm.number2=''
        this.ruleForm.number3=''
        this.ruleForm.number4=''
        this.ruleForm.number5=''
      },
      openDialog() {
        this.ruleForm.branchName = ''
        this.ruleForm.branchNO = ''
        if (this.$refs['ruleForm'] != undefined) {
          this.$refs['ruleForm'].clearValidate();
          this.$refs['ruleForm'].resetFields();
        }
        this.actQuery('01')
        this.actQuery('02')
      },
      // 规则类型修改
      ruleTypeChange(val) {
        // console.log(val)
        this.ruleTypeName = val == '1' ? '坐席必须工作' : '坐席必须休假'
        this.ruleForm.OPERPERIOD = ''
        this.ruleForm.OPERUNIT = ''
        this.ruleForm.value1 = ''
        this.ruleForm.value2 = ''
        this.ruleForm.value4 = ''
        // this.ruleForm.value5 = ''
        this.ruleForm.VALUEX = ''
        this.ruleForm.VALUEX1 = ''
        this.ruleForm.VALUEX2 = ''
        this.ruleForm.VALUEX3 = ''
        this.ruleForm.number= ''
        this.ruleForm.number1=''
        this.ruleForm.number2=''
        this.ruleForm.number3=''
        this.ruleForm.number4=''
        this.ruleForm.number5=''
      },
      // 重置
      resetForm(formName) {
        this.$refs[formName].resetFields();
        this.$refs[formName].clearValidate();
        this.ruleForm.OPERPERIOD = ''
        this.ruleForm.OPERUNIT = ''
        this.ruleForm.value1 = ''
        this.ruleForm.value2 = ''
        this.ruleForm.value4 = ''
        // this.ruleForm.value5 = ''
        this.ruleForm.VALUEX = ''
        this.ruleForm.VALUEX1 = ''
        this.ruleForm.VALUEX2 = ''
        this.ruleForm.VALUEX3 = ''
        this.ruleForm.number= ''
        this.ruleForm.number1=''
        this.ruleForm.number2=''
        this.ruleForm.number3=''
        this.ruleForm.number4=''
        this.ruleForm.number5=''
      },
      //保存
      submitForm(formName) {
        this.$refs[formName].validate(async (valid) => {
          if (valid) {
            let resBody = new Add()
            resBody.data.BRANCHNO = this.ruleForm.branchNO
            resBody.data.OPERUNITVALUE = '-1'
            resBody.data.VALUEX = '-1'
            resBody.data.UNITMINVALUE = '-1'
            resBody.data.UNITMAXVALUE = '-1'
            if(this.ruleForm.number=='1'){
              resBody.data.UNITMINVALUE = this.ruleForm.number1
            }else if(this.ruleForm.number=='2'){
              resBody.data.UNITMAXVALUE = this.ruleForm.number2
            }else if(this.ruleForm.number=='3'){
              resBody.data.UNITMAXVALUE = this.ruleForm.number3
              resBody.data.UNITMINVALUE = this.ruleForm.number3
            }else if(this.ruleForm.number=='4'){
              resBody.data.UNITMINVALUE = this.ruleForm.number4
              resBody.data.UNITMAXVALUE = this.ruleForm.number5
            }
            resBody.data.EFFECTDATE = this.ruleForm.EFFECTDATE
            resBody.data.FAILUREDATE = this.ruleForm.FAILUREDATE
            resBody.data.ASSIGNRULENAME = this.ruleForm.ASSIGNRULENAME
            resBody.data.PRIORITY = this.ruleForm.PRIORITY
            resBody.data.RULETYPE = this.ruleForm.RULETYPE
            resBody.data.OPERUNIT = this.ruleForm.OPERUNIT
            if (this.ruleForm.OPERUNIT == '1') {
              resBody.data.OPERUNITVALUE = this.ruleForm.value1
            } else if (this.ruleForm.OPERUNIT == '2') {
              resBody.data.OPERUNITVALUE = this.ruleForm.value2
            } else if (this.ruleForm.OPERUNIT == '4') {
              resBody.data.OPERUNITVALUE = this.ruleForm.value4
            } else if (this.ruleForm.OPERUNIT == '5') {
              // resBody.data.OPERUNITVALUE = this.ruleForm.value5
            }
            resBody.data.OPERPERIOD = this.ruleForm.OPERPERIOD
            if (this.ruleForm.OPERPERIOD == '1') {
              resBody.data.VALUEX = this.ruleForm.VALUEX1
            } else if (this.ruleForm.OPERPERIOD == '2') {
              resBody.data.VALUEX = this.ruleForm.VALUEX2
            } else if (this.ruleForm.OPERPERIOD == '3') {
              resBody.data.VALUEX = this.ruleForm.VALUEX3
            }
            let response = await request(resBody);
            if (response.SYS_HEAD.ReturnCode == "000000") {
              this.option.isShow = false
              this.$refs[formName].resetFields();
              this.$refs[formName].clearValidate();
              this.$emit("ListenAssign")
            } else {
              this.$message({
                type: "error",
                message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD
                  .ReturnMessage
              })
            }

          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },

    }
  };

</script>

<style scoped lang="scss">
  .selectStyle {
    width: 100px;
  }

</style>
